/* -----------------------------------------------------------------------
 * Demonstration of how to write unit tests for dominion-base
 * Include the following lines in your makefile:
 *
 * unittest2: unittest2.c dominion.o rngs.o
 *      gcc -o testUpdateCoins -g  unittest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int main() {
	//testing gainCard
	struct gameState G;
	int numPlayer = 2;
	int seed = 2;
	int player = 0;//just player 0 for now
	int k[10] = {adventurer, council_room, feast, gardens, mine
		, remodel, smithy, village, baron, great_hall};
	
	initializeGame(numPlayer, k, seed, &G); // initialize a new game, and record the number of cards in each pile
	//printf("The number of cards in the discard pile is: %d\n",G.discardCount[player]);
	//printf("The number of cards in the deck pile is: %d\n",G.deckCount[player]);
	//printf("The number of cards in the player's hand is: %d\n",G.handCount[player]);
	int startingDiscardCount = G.discardCount[player];
	int startingDeckCount = G.deckCount[player];
	int startingHandCount = G.handCount[player];
	
	
	
	printf("Adding a card to each pile\n");//add a card to each pile, then check that a card was added
	int testGainCard = gainCard(estate,&G,0,player);//0 = discard, 1= deck, 2 = hand
	testGainCard = gainCard(estate,&G,1,player);
	testGainCard = gainCard(estate,&G,2,player);
	//printf("The number of cards in the discard pile is: %d\n",G.discardCount[player]);
	//printf("The number of cards in the deck pile is: %d\n",G.deckCount[player]);
	//printf("The number of cards in the player's hand is: %d\n",G.handCount[player]);
	if ((G.discardCount[player] == (startingDiscardCount+1))  && (G.deckCount[player] == (startingDeckCount+1)) && (G.handCount[player] == (startingHandCount+1)) ) {
		printf("Passed simple card adding\n");
	}
	else {
		printf("Failed simple card adding");
	}

	
	//try to add a card we are out of supply to each pile
	initializeGame(numPlayer, k, seed, &G); // initialize a new game to clear above test, and record the number of cards in each pile
	G.supplyCount[estate]= 0;
	//printf("Adding a card to each pile\n");//add a card to each pile, then check that a card was added
	testGainCard = gainCard(estate,&G,0,player);//0 = discard, 1= deck, 2 = hand
	testGainCard = gainCard(estate,&G,1,player);
	testGainCard = gainCard(estate,&G,2,player);
	//printf("The number of cards in the discard pile is: %d\n",G.discardCount[player]);
	//printf("The number of cards in the deck pile is: %d\n",G.deckCount[player]);
	//printf("The number of cards in the player's hand is: %d\n",G.handCount[player]);
	if ((G.discardCount[player] == (startingDiscardCount))  && (G.deckCount[player] == (startingDeckCount)) && (G.handCount[player] == (startingHandCount)) ) {
		printf("Passed overdrawing cards test\n");
	}
	else {
		printf("Failed overdrawing cards test");
	}
	
	//this time watch the supply to make sure it works properly
	initializeGame(numPlayer, k, seed, &G); // initialize a new game to clear above test, and record the number of cards in each pile
	int startingEstateSupply = G.supplyCount[estate];
	printf("Adding a card to each pile\n");//add a card to each pile, then check that a card was added
	testGainCard = gainCard(estate,&G,0,player);//0 = discard, 1= deck, 2 = hand
	if (G.supplyCount[estate]==(startingEstateSupply - 1)) {
		printf("Passed decrementing supply\n");
	}


	
	return 0;
}
